Skip to content

Fix Source targetPath incorrectly aligned to project basedir#12178

Closed
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/resource-targetpath
Closed

Fix Source targetPath incorrectly aligned to project basedir#12178
gnodet wants to merge 1 commit into
apache:masterfrom
gnodet:fix/resource-targetpath

Conversation

@gnodet

@gnodet gnodet commented May 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • DefaultModelPathTranslator.alignToBaseDirectory(Source) was incorrectly resolving Source.targetPath against the project basedir, turning a relative path like .grammar into an absolute path like /path/to/project/.grammar
  • This caused the maven-resources-plugin to write files to incorrect absolute locations instead of relative to the output directory (target/classes)
  • Removed the targetPath alignment from Source path translation, matching the existing behavior for Resource.targetPath (which is correctly not aligned)

Test plan

  • New DefaultModelPathTranslatorTest — verifies Source targetPath is NOT aligned while directory IS aligned
  • New ProjectBuilderTest#testSourceTargetPathRemainsRelative — full model builder integration test with .grammar and META-INF/test targetPaths, verifying both SourceRoot API and compat Resource API
  • Existing PomConstructionTest#testTargetPathResourceRegression — still passes
  • Existing ResourceIncludeTest (10 tests) — still passes
  • Existing DefaultSourceRootTest (13 tests) — still passes
  • Full test suite for maven-impl and maven-core (547 tests) — all pass

Claude Code on behalf of Guillaume Nodet

🤖 Generated with Claude Code

gnodet added a commit that referenced this pull request May 28, 2026
Cherry-pick from fix/resource-targetpath branch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-6 milestone May 28, 2026
@gnodet gnodet requested a review from desruisseaux May 29, 2026 11:10
@gnodet gnodet force-pushed the fix/resource-targetpath branch from fde9762 to 7811510 Compare June 1, 2026 19:19
DefaultModelPathTranslator.alignToBaseDirectory(Source) was resolving
Source.targetPath against the project basedir, turning relative paths
like "META-INF/tags/rdc" into absolute paths. This caused
maven-resources-plugin to write files to incorrect absolute locations
instead of relative to the output directory (target/classes).

Removed the targetPath alignment from Source path translation, matching
the existing correct behavior for Resource.targetPath.

Added test coverage for both Source (4.1.0 model) and legacy Resource
(4.0.0 model) targetPath through the compat layer.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet force-pushed the fix/resource-targetpath branch from 7811510 to 11c30c2 Compare June 1, 2026 19:24
gnodet added a commit that referenced this pull request Jun 1, 2026
Cherry-pick from fix/resource-targetpath branch (squashed commit).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gnodet added a commit that referenced this pull request Jun 2, 2026
Cherry-pick from fix/resource-targetpath-compat branch.
Supersedes earlier #12178 cherry-pick with expanded fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Bukama

Bukama commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Is this PR and #12206 the same?

@gnodet

gnodet commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #12206 which covers the same fix (Source.targetPath alignment to basedir) with consolidated tests from both PRs. The core fix in DefaultModelPathTranslator is identical; #12206 now includes the stronger assertions and test coverage from this PR.

@gnodet gnodet closed this Jun 4, 2026
@github-actions github-actions Bot removed this from the 4.0.0-rc-6 milestone Jun 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants